import requests
import json

def getGroup(match_id):
    url = 'https://gameinfo.365raylines.com/v2/odds?match_id='+str(match_id)
    r = requests.get(url)
    if r.status_code==200:
        res=json.loads(r.text,encoding='utf-8')
        err_code = res['code']
        if err_code == 200:
            result = res['result']
            odds_list =  result['odds']
            new_odds = {}
            for odds in odds_list:
                if odds['odds_group_id'] not in new_odds.keys():
                    new_odds[odds['odds_group_id']] = {}
                new_odds[odds['odds_group_id']].update({
                        odds['odds_id']:odds['group_name']+'-'+odds['match_stage']+'-'+odds['name']+'-'+odds['tag']
                    })
        print(new_odds)
        with open("odds_group.txt","w") as f:
            f.write(json.dumps(new_odds, sort_keys=True, indent=2,ensure_ascii=False)) 
        



getGroup(37435358)